home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 2000
/
MacHack 2000.toast
/
pc
/
The Hacks
/
Boxer
/
MacUnBoxer
/
SimpleAlert.c
< prev
Wrap
C/C++ Source or Header
|
2000-06-23
|
2KB
|
120 lines
/*
* C Toolbox Stationery
* by Josef W. Wankerl
* 04/11/00
*/
#include <Dialogs.h>
#include <Fonts.h>
#include <MacWindows.h>
#include <Menus.h>
#include <QuickDraw.h>
#include <TextEdit.h>
#include <string.h>
#include <stdio.h>
enum
{
kAlertID = 128
};
static void Initialize(void)
{
InitGraf(&qd.thePort);
InitFonts();
InitWindows();
InitMenus();
TEInit();
InitDialogs(nil);
InitCursor();
}
StandardFileReply reply;
#define htonl(x) x
#define htons(x) x
struct prchead {
char name[32]; //0-32
short int attr; //32-33
short int vers; //34-35
long int cr, md, bkt; //times 36-47
long int mn, app, sort; // zero 48-59 - zero for prcs.
long int type, crea; //60-67
long int uidseed, nxrec; //68-75 - uidseed rand, nxrec zero;
short int nrecs; //76-78
} head;
#define title argv[1]
void main(void)
{
unsigned long cofst;
char bbuf[5000], nbuf[32];
unsigned short xshort;
unsigned long xlong, xid,xlong2;
long bbuflen;
int maxsect,i;
char argv[2][80];
FILE *outfd, *infd;
Initialize();
StandardGetFile(NULL,0,NULL,&reply);
strcpy(argv[1],(char *) reply.sfFile.name);
{
infd = fopen(argv[1],"r");
fread(&head, 1,sizeof(head),infd);
fread(&xlong, 1,4,infd);
maxsect = htons(head.nrecs);
cofst = htonl(xlong);
if (!strcmp(&title[strlen(title) - 4], ".pdb"))
title[strlen(title) - 4] = 0;
else
strcat(title, ".out");
outfd = fopen(title, "w");
for (i = 0; i < maxsect; i++) {
fread( title, 1,4,infd);
if (i + 1 != maxsect) {
fread( &xlong2,1, 4,infd);
bbuflen = htonl(xlong2);
bbuflen = bbuflen - cofst;
} else
bbuflen = 4096 + 8;
if (bbuflen > 8400 || bbuflen < 8)
exit(-3);
xlong = fseek(infd, 0, SEEK_CUR);
fseek(infd, cofst, SEEK_SET);
fread(bbuf, 1,4,infd);
if (strncmp(bbuf, "DBLK", 4))
exit(-2);
fread( &cofst, 1,4,infd);
bbuflen -= 8;
bbuflen = fread(bbuf, 1,bbuflen,infd);
fseek(infd, xlong, SEEK_SET);
cofst = htonl(xlong2);
fwrite( bbuf, 1,bbuflen,outfd);
}
fclose(outfd);
fclose(infd);
}
}